<?php
require($_SERVER['DOCUMENT_ROOT'].'/cofd/common.php');
$resultData = [
    "code" => 0,
    "msg" => "",
    "count" => 0,
    "data" => []
];
try {
    $sql = "SELECT * FROM report";
    $stmt = $conn->prepare($sql);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $reid = $row['id'];
            $fileid = $row['fileid'];
            $reason = $row['reason']; 
            $filename = $row['filename'];
            $retime = $row['timei'];
            $resultData['data'][] = [
                "reportid" => $reid,
                "fileid" => $fileid,
                "reason" => $reason,
                "filename" => $filename,
                "reportime" => $retime,
                'userid'=> $row['userid'],
                'beuserid'=> $row['beuserid'],
            ];
            $resultData['count']++;
        }
    } else {
        $resultData['msg'] = "未找到举报数据";
    }
} catch (Exception $e) {
    $resultData['code'] = 1;
    $resultData['msg'] = "查询失败：" . $e->getMessage();
}
echo json_encode($resultData, JSON_UNESCAPED_UNICODE);